<?php
if(!defined('ACCESS')) {exit('Access denied.');}
class Phone extends Base {
	// 表名
	private static $table_name = 'card';
	// 查询字段
	private static $columns = 'id,team_name,team_type';
	
	public static function getTableName(){
		return "tb_phone";
	}

	public static function getList() {
		$db=self::__instance();
		$conditon=array();

		$sql= "SELECT 
				    *
				FROM
				    tb_phone order by create_time desc";
		$list = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC);// self::getTableName(), self::$columns, $condition );
	
		if ($list) {
			return $list;
		}
		return  array();
	}

	public static function count() {
		$db=self::__instance();
		$conditon=array();

		$sql= "SELECT 
				    count(*) as count
				FROM
				    tb_phone order by create_time desc";
		$list = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC);// self::getTableName(), self::$columns, $condition );
	
		if ($list) {
			return $list[0]["count"];
		}
		return  array();
	}

	public static function getById($sim=null) {
		$db=self::__instance();
		
		$sql= "select * from tb_phone where id=$sim";
		$list = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC);// self::getTableName(), self::$columns, $condition );

		if ($list) {
			return $list[0];
		}
		return array ();
	}


	public static function add($array) {
		$db=self::__instance();
		$id = $db->insert ( "tb_phone", $array );
		
		return $id;
	}

	public static function delete($vs_id) {

		$condition['AND']=array("id"=>$vs_id);
		$db=self::__instance();
		$id = $db->delete ( self::getTableName() ,$condition);
		return $id;
	}
}
